const effectMap = {};
// 多次修改同一个key，只执行最后一次
export default function scheduler(enffectFn, key) {
  if (typeof enffectFn !== "function") {
    throw new Error("scheduler: enffectFn must be a function");
  }
  if (key in effectMap) {
    let timer = effectMap[key];
    clearTimeout(timer);
    timer = setTimeout(enffectFn);
    effectMap[key] = timer;
    return;
  }
  const timer = setTimeout(enffectFn);
  effectMap[key] = timer;
}
